package zhzz;

//这个类同样没有对数据进行处理只有简单的跳转
import java.io.Serializable;
import java.util.ArrayList;

import com.example.animaldoctor03.AllIllness;
import com.example.animaldoctor03.R;

import commonClass.FunctionDispatcher;
import commonClass.QueryAllNoAnatomySymptomsCategorieByAnimalIDAction;
import commonClass.RemoteActionsName;
import commonClass.FunctionDispatcher.IRequestCompeletListener;
import Modle.disease.SymptomsCategorie;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

public class PartIllnessOfZH extends Activity {
	private Button btofPItock;
	
	private ListView listofPIofzh ;
	private String animalID = "01371054603";
	private ArrayList<Object> resultListofPartIofzh = null;
	private void chushihuaofPI() {
		setContentView(R.layout.partinessofzh);
		btofPItock = (Button) findViewById(R.id.btoPInessofzh3);
		listofPIofzh = (ListView)findViewById(R.id.listofPInessofzh);

		btofPItock.setOnClickListener(new listenerofPItock());

	}
	private ArrayList<Object> assembly() {

		ArrayList<Object> list = new ArrayList<Object>();

		list.add(animalID);
		// Integer i = new Integer(10);
		// list.add(i);

		return list;
	}
private void binding(final ArrayList<Object> list) {
		
		try{	
			String[] resultofZZFZ1 = new String[list.size()];
			// list.toArray(new String[list.size()]);
			for (int i = 0; i < list.size(); i++) {
				
				
				//haiyouwenti
				resultofZZFZ1[i] = ((SymptomsCategorie) list.get(i)).getSymptomsCategorieName();
			}
			ArrayAdapter<String> arrayAdapterofResult = new ArrayAdapter<String>(
					this, android.R.layout.simple_list_item_1, resultofZZFZ1);
			listofPIofzh.setAdapter(arrayAdapterofResult);
			
			listofPIofzh.setOnItemClickListener(new OnItemClickListener() {

					public void onItemClick(AdapterView<?> parent, View view, int position,
							long id) {
						// TODO Auto-generated method stub
						Bundle bundleofAIDofzh = new Bundle();
						bundleofAIDofzh.putSerializable("shuju", (Serializable) list.get(position));
						Intent intent = new Intent (PartIllnessOfZH.this , IllnessDetailofRqst.class);
						intent.putExtras(bundleofAIDofzh);
						startActivity(intent);
						finish();
						
					}
	 
			 });
			 }catch(NullPointerException e){
				 
				 android.app.AlertDialog.Builder builderofZZFZ = new AlertDialog.Builder(PartIllnessOfZH.this);
				 builderofZZFZ.setMessage("无数据，请用其他功能");
				 builderofZZFZ.create().show();
			 }

	}
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		chushihuaofPI();
		assembly();
		ArrayList<Object> parasList = assembly();
		final ArrayList<Object> resultListT = null;
		
		QueryAllNoAnatomySymptomsCategorieByAnimalIDAction iAction = new QueryAllNoAnatomySymptomsCategorieByAnimalIDAction();

		FunctionDispatcher functionDispacher = new FunctionDispatcher();

		functionDispacher.exceute(
				RemoteActionsName.QueryAllNoAnatomySymptomsCategorieByAnimalIDAction, parasList,
				iAction, new IRequestCompeletListener() {

					@Override
					public void doCompelet(ArrayList<Object> resultList) {
						// TODO Auto-generated method stub
						PartIllnessOfZH.this.resultListofPartIofzh = resultList;
						binding(resultListofPartIofzh);
					}
				} ,this);

	}

	private class listenerofPItock implements OnClickListener {

		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			Intent intentofPItock = new Intent(PartIllnessOfZH.this,
					ChoiceDetail.class);
			startActivity(intentofPItock);
			finish();
		}

	}

}
